﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using BLL.SystemManagement;
using System.Data;
using System.Collections.ObjectModel;
using Garlic.DM.DataModel;

namespace Garlic.WcfService
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "ServiceForSL" in code, svc and config file together.
    public class ServiceForSL : IServiceForSL
    {
        public void DoWork()
        {
        }

        /// <summary>
        /// 获取船代理的名称。
        /// </summary>
        /// <param name="temUserID"></param>
        /// <returns></returns>
        public string GetCustomerName(int temUserID)
        {
            DataTable customer = FlightInfoBLL.GetShipAgency(temUserID);
            if (customer != null && customer.Rows.Count > 0)
            {
                return customer.Rows[0]["cst_cstmnm"].ToString();
            }
            else
                return "";
        }

        /// <summary>
        /// 根据用户ID，类型获得主航线。
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="userType"></param>
        /// <returns></returns>
        public List<MainSeaRoutes> GetMainSeaRoutes_ByUserId(int userID, string userType)
        {
            DataTable dt = ServiceRouteTreeBLL.GetRoutes1(userID, userType);
            List<MainSeaRoutes> listMainSeaRoutes = new List<MainSeaRoutes>();
            foreach (DataRow item in dt.Rows)
            {
                MainSeaRoutes msr = new MainSeaRoutes();
                int mid = 0;
                int.TryParse(item[0].ToString(), out mid);
                msr.ID = mid;
                msr.RouteName = item[1].ToString();
                //msr.RTCD = item[2].ToString();
                listMainSeaRoutes.Add(msr);
            }
            return listMainSeaRoutes;
        }

        /// <summary>
        /// 根据用户ID，类型、主航线获得此航线下所有的子航线。
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="userType"></param>
        /// <param name="sln_srt_id"></param>
        /// <returns></returns>
        public List<MainSeaRoutes> GetChildSeaRoutes_ByLineID(int userID, string userType, int sln_srt_id)
        {
            List<MainSeaRoutes> listMainSeaRoutes = new List<MainSeaRoutes>();
            using (DataTable table2 = ServiceRouteTreeBLL.GetRoutes2(userID, userType, sln_srt_id))
            {
                if (table2.Rows.Count > 0)
                {
                    for (int j = 0; j < table2.Rows.Count; j++)
                    {
                        using (DataTable table3 = ServiceRouteTreeBLL.GetRoutes3(userID, userType, Convert.ToInt32(table2.Rows[j][0])))
                        {
                            if (table3.Rows.Count > 0)
                            {
                                for (int k = 0; k < table3.Rows.Count; k++)
                                {
                                    MainSeaRoutes msr3 = new MainSeaRoutes();
                                    msr3.ID = int.Parse(table3.Rows[k][0].ToString());
                                    msr3.RouteName = table2.Rows[j][1].ToString() + "(" + table2.Rows[j][2].ToString() + ")";
                                    msr3.ChildRouteName = table3.Rows[k][1].ToString() + "(" + table3.Rows[k][2].ToString() + ")";
                                    msr3.CST_CSTM = table3.Rows[k][3].ToString();
                                    listMainSeaRoutes.Add(msr3);
                                }
                            }
                            else
                            {
                                MainSeaRoutes msr2 = new MainSeaRoutes();
                                msr2.ID = int.Parse(table2.Rows[j][0].ToString());
                                msr2.RouteName = table2.Rows[j][1].ToString() + "(" + table2.Rows[j][2].ToString() + ")";
                                msr2.CST_CSTM = table2.Rows[j][3].ToString();
                                listMainSeaRoutes.Add(msr2);
                            }
                        }
                    }
                }
            }
            return listMainSeaRoutes;
        }

        /// <summary>
        /// 根据用户ID，服务航线ID得到班期。
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="serviceLineID"></param>
        /// <returns></returns>
        public List<MainSeaRoutes> GetVesselDate(int userid, string serviceLineID)
        {
            DataTable shipAgent = FlightInfoBLL.GetShipAgency(userid);
            if (shipAgent.Rows.Count == 0) return null;
            int? agentID = Int32.Parse(shipAgent.Rows[0]["cst_id"].ToString());
            if (userid == 1)
                agentID = null;
            List<MainSeaRoutes> listRoute = new List<MainSeaRoutes>();
            if (!string.IsNullOrEmpty(serviceLineID))
            {
                DataTable flt_schdul = FlightInfoBLL.GetFlightScheduleBySln(agentID, serviceLineID);
                foreach (DataRow item in flt_schdul.Rows)
                {
                    MainSeaRoutes msr = new MainSeaRoutes();
                    msr.RouteName = item["FLT_SCHDUL"].ToString();
                    msr.ID = int.Parse(item["FLT_ID"].ToString());
                    listRoute.Add(msr);
                }
            }
            //MainSeaRoutes msrNo = new MainSeaRoutes();// 添加“未定”项.
            //msrNo.RouteName = "未定";
            //msrNo.ID = 1628; // 从数据库里得到。
            //listRoute.Add(msrNo);
            return listRoute;
        }

        /// <summary>
        /// 得到预分码头
        /// </summary>
        /// <param name="flt_sln_id"></param>
        /// <returns></returns>
        public List<MainSeaRoutes> GetTermail(int flt_sln_id)
        {
            List<MainSeaRoutes> listMSR = new List<MainSeaRoutes>();
            DataTable flt_schdul = FlightInfoBLL.GetFlt_schdulDataTable(flt_sln_id);
            foreach (DataRow item in flt_schdul.Rows)
            {
                MainSeaRoutes msr = new MainSeaRoutes();
                msr.ID = int.Parse(item["FLT_TER_CST_ID"] == null ? "0" : item["FLT_TER_CST_ID"].ToString());//预分码头ID
                msr.RouteName = item["cst_cstmcd"] == null ? "" : item["cst_cstmcd"].ToString();//预分码头简称
                listMSR.Add(msr);
            }
            return listMSR;
        }

        /// <summary>
        /// 得到预分码头,根据
        /// </summary>
        /// <param name="flt_sln_id"></param>
        /// <returns></returns>
        public List<MainSeaRoutes> GetTermail_Schedule(int flt_sln_id, int flt_id)
        {
            List<MainSeaRoutes> listMSR = new List<MainSeaRoutes>();
            DataTable flt_schdul = FlightInfoBLL.GetFlt_schdulDataTable(flt_sln_id, flt_id);
            foreach (DataRow item in flt_schdul.Rows)
            {
                MainSeaRoutes msr = new MainSeaRoutes();
                msr.ID = int.Parse(item["FLT_TER_CST_ID"] == null ? "0" : item["FLT_TER_CST_ID"].ToString());//预分码头ID
                msr.RouteName = item["cst_cstmcd"] == null ? "" : item["cst_cstmcd"].ToString();//预分码头简称
                listMSR.Add(msr);
            }
            return listMSR;
        }

        /// <summary>
        /// 得到船公司名称。
        /// </summary>
        /// <param name="sln_id"></param>
        /// <returns></returns>
        public string GetVesselName(int sln_id)
        {
            return ServiceRouteTreeBLL.GetVesselName(sln_id);
        }

        /// <summary>
        /// 得到所有船期信息。
        /// </summary>
        /// <returns></returns>
        public List<UM_VesselSchedules> GetVesselSchedules(string whereStr, string orderbyStr)
        {
            List<UM_VesselSchedules> list_VS = new List<UM_VesselSchedules>();
            BLL.BusinessDeal.StSchedulesManager ssm = new BLL.BusinessDeal.StSchedulesManager();

            DataTable dt = ssm.GetTable(whereStr, orderbyStr);
            foreach (DataRow item in dt.Rows)
            {
                UM_VesselSchedules um_vs = new UM_VesselSchedules();
                if (item["CST_CSTM"] != null && !string.IsNullOrEmpty(item["CST_CSTM"].ToString().Trim()))
                {
                    um_vs.CST_CSTM = item["CST_CSTM"].ToString();
                }
                if (item["POT_FNAME"] != null && !string.IsNullOrEmpty(item["POT_FNAME"].ToString().Trim()))
                {
                    um_vs.POT_FNAME = item["POT_FNAME"].ToString();
                }
                if (item["POT_NNAME"] != null && !string.IsNullOrEmpty(item["POT_NNAME"].ToString().Trim()))
                {
                    um_vs.POT_NNAME = item["POT_NNAME"].ToString();
                }

                if (item["RV_MEANING"] != null && !string.IsNullOrEmpty(item["RV_MEANING"].ToString().Trim()))
                {
                    um_vs.RV_MEANING = item["RV_MEANING"].ToString();
                }
                if (item["SCD_CULOC"] != null && !string.IsNullOrEmpty(item["SCD_CULOC"].ToString().Trim()))
                {
                    um_vs.SCD_CULOC = item["SCD_CULOC"].ToString();
                }
                if (item["SCD_ETA"] != null && !string.IsNullOrEmpty(item["SCD_ETA"].ToString().Trim()))
                {
                    um_vs.SCD_ETA = DateTime.Parse(item["SCD_ETA"].ToString());
                }
                if (item["SCD_ETD"] != null && !string.IsNullOrEmpty(item["SCD_ETD"].ToString().Trim()))
                {
                    um_vs.SCD_ETD = DateTime.Parse(item["SCD_ETD"].ToString());
                }
                if (item["SCD_EVOYAGE"] != null && !string.IsNullOrEmpty(item["SCD_EVOYAGE"].ToString().Trim()))
                {
                    um_vs.SCD_EVOYAGE = item["SCD_EVOYAGE"].ToString();
                }
                if (item["SCD_FIXSCDSHPFG"] != null && !string.IsNullOrEmpty(item["SCD_FIXSCDSHPFG"].ToString().Trim()))
                {
                    um_vs.SCD_FIXSCDSHPFG = item["SCD_FIXSCDSHPFG"].ToString();
                }
                if (item["SCD_ID"] != null && !string.IsNullOrEmpty(item["SCD_ID"].ToString().Trim()))
                {
                    um_vs.SCD_ID = decimal.Parse(item["SCD_ID"].ToString());
                }
                if (item["SCD_IVOYAGE"] != null && !string.IsNullOrEmpty(item["SCD_IVOYAGE"].ToString().Trim()))
                {
                    um_vs.SCD_IVOYAGE = item["SCD_IVOYAGE"].ToString();
                }
                if (item["SCD_PILOTAGE"] != null && !string.IsNullOrEmpty(item["SCD_PILOTAGE"].ToString().Trim()))
                {
                    um_vs.SCD_PILOTAGE = item["SCD_PILOTAGE"].ToString();
                }
                if (item["SCD_STATUS"] != null && !string.IsNullOrEmpty(item["SCD_STATUS"].ToString().Trim()))
                {
                    um_vs.SCD_STATUS = item["SCD_STATUS"].ToString();
                }
                if (item["VSL_CNNAME"] != null && !string.IsNullOrEmpty(item["VSL_CNNAME"].ToString().Trim()))
                {
                    um_vs.VSL_CNNAME = item["VSL_CNNAME"].ToString();
                }
                if (item["VSL_ENNAME"] != null && !string.IsNullOrEmpty(item["VSL_ENNAME"].ToString().Trim()))
                {
                    um_vs.VSL_ENNAME = item["VSL_ENNAME"].ToString();
                }
                if (item["VSL_VTPCODE"] != null && !string.IsNullOrEmpty(item["VSL_VTPCODE"].ToString().Trim()))
                {
                    um_vs.VSL_VTPCODE = item["VSL_VTPCODE"].ToString();
                }
                if (item["SERVICELINE"] != null && !string.IsNullOrEmpty(item["SERVICELINE"].ToString()))
                {
                    um_vs.SERVICELINE = item["serviceLine"].ToString();
                }
                list_VS.Add(um_vs);
            }

            return list_VS;
        }

        /// <summary>
        ///  船期的靠泊数据
        /// </summary>
        /// <param name="SCD_ID"></param>
        /// <returns></returns>
        public List<UM_Vessel_Berthes> GetVesselBerthes(decimal SCD_ID)
        {
            List<UM_Vessel_Berthes> list_VB = new List<UM_Vessel_Berthes>();
            Garlic.BLL.BusinessDeal.StVesselBerthesManager ssm = new BLL.BusinessDeal.StVesselBerthesManager();

            DataTable dt = ssm.GetTable("vbt_scd_id = " + SCD_ID.ToString(), string.Empty);
            foreach (DataRow item in dt.Rows)
            {
                UM_Vessel_Berthes um_vb = new UM_Vessel_Berthes();
                if (item["CST_CSTM"] != null && !string.IsNullOrEmpty(item["CST_CSTM"].ToString().Trim()))
                {
                    um_vb.CST_CSTM = item["CST_CSTM"].ToString();
                }
                if (item["SCD_IE_VOYAGE"] != null && !string.IsNullOrEmpty(item["SCD_IE_VOYAGE"].ToString().Trim()))
                {
                    um_vb.SCD_IE_VOYAGE = item["SCD_IE_VOYAGE"].ToString();
                }
                if (item["VBT_LDUNLDFG"] != null && !string.IsNullOrEmpty(item["VBT_LDUNLDFG"].ToString().Trim()))
                {
                    um_vb.VBT_LDUNLDFG = item["VBT_LDUNLDFG"].ToString();
                }
                if (item["VBT_STATUS"] != null && !string.IsNullOrEmpty(item["VBT_STATUS"].ToString().Trim()))
                {
                    um_vb.VBT_STATUS = item["VBT_STATUS"].ToString();
                }
                if (item["VBT_STATUS_MEANING"] != null && !string.IsNullOrEmpty(item["VBT_STATUS_MEANING"].ToString().Trim()))
                {
                    um_vb.VBT_STATUS_MEANING = item["VBT_STATUS_MEANING"].ToString();
                }
                if (item["VBT_BERTHTIMES"] != null && !string.IsNullOrEmpty(item["VBT_BERTHTIMES"].ToString().Trim()))
                {
                    um_vb.VBT_BERTHTIMES = decimal.Parse(item["VBT_BERTHTIMES"].ToString());
                }
                if (item["VBT_ID"] != null && !string.IsNullOrEmpty(item["VBT_ID"].ToString().Trim()))
                {
                    um_vb.VBT_ID = decimal.Parse(item["VBT_ID"].ToString());
                }
                if (item["VBT_PBTHDRAFT"] != null && !string.IsNullOrEmpty(item["VBT_PBTHDRAFT"].ToString().Trim()))
                {
                    um_vb.VBT_PBTHDRAFT = decimal.Parse(item["VBT_PBTHDRAFT"].ToString());
                }
                if (item["VBT_PBTHDRAFT_A"] != null && !string.IsNullOrEmpty(item["VBT_PBTHDRAFT_A"].ToString().Trim()))
                {
                    um_vb.VBT_PBTHDRAFT_A = decimal.Parse(item["VBT_PBTHDRAFT_A"].ToString());
                }
                if (item["VBT_PBTHDRAFT_P"] != null && !string.IsNullOrEmpty(item["VBT_PBTHDRAFT_P"].ToString().Trim()))
                {
                    um_vb.VBT_PBTHDRAFT_P = decimal.Parse(item["VBT_PBTHDRAFT_P"].ToString());
                }
                if (item["VBT_PBTHDT"] != null && !string.IsNullOrEmpty(item["VBT_PBTHDT"].ToString().Trim()))
                {
                    um_vb.VBT_PBTHDT = DateTime.Parse(item["VBT_PBTHDT"].ToString());
                }
                if (item["VBT_PDPTDRAFT"] != null && !string.IsNullOrEmpty(item["VBT_PDPTDRAFT"].ToString().Trim()))
                {
                    um_vb.VBT_PDPTDRAFT = decimal.Parse(item["VBT_PDPTDRAFT"].ToString());
                }
                if (item["VBT_PDPTDRAFT_A"] != null && !string.IsNullOrEmpty(item["VBT_PDPTDRAFT_A"].ToString().Trim()))
                {
                    um_vb.VBT_PDPTDRAFT_A = decimal.Parse(item["VBT_PDPTDRAFT_A"].ToString());
                }
                if (item["VBT_PDPTDRAFT_P"] != null && !string.IsNullOrEmpty(item["VBT_PDPTDRAFT_P"].ToString().Trim()))
                {
                    um_vb.VBT_PDPTDRAFT_P = decimal.Parse(item["VBT_PDPTDRAFT_P"].ToString());
                }
                if (item["VBT_PDPTDT"] != null && !string.IsNullOrEmpty(item["VBT_PDPTDT"].ToString().Trim()))
                {
                    um_vb.VBT_PDPTDT = DateTime.Parse(item["VBT_PDPTDT"].ToString());
                }
                if (item["VBT_SCD_ID"] != null && !string.IsNullOrEmpty(item["VBT_SCD_ID"].ToString().Trim()))
                {
                    um_vb.VBT_SCD_ID = decimal.Parse(item["VBT_SCD_ID"].ToString());
                }
                if (item["VSL_ENNAME"] != null && !string.IsNullOrEmpty(item["VSL_ENNAME"].ToString().Trim()))
                {
                    um_vb.VSL_ENNAME = item["VSL_ENNAME"].ToString();
                }
                if (item["vsl_cnname"] != null && !string.IsNullOrEmpty(item["vsl_cnname"].ToString().Trim()))
                {
                    um_vb.VSL_CNNAME = item["vsl_cnname"].ToString();
                }
                list_VB.Add(um_vb);
            }
            return list_VB;
        }

        /// <summary>
        ///  船期的航次数据。
        /// </summary>
        /// <param name="SCD_ID"></param>
        /// <returns></returns>
        public List<UM_Voyages> GetVoyages(decimal SCD_ID)
        {
            List<UM_Voyages> list_Voyage = new List<UM_Voyages>();
            Garlic.BLL.BusinessDeal.StVoyagesManager ssm = new BLL.BusinessDeal.StVoyagesManager();

            DataTable dt = ssm.GetTable(" voy_scd_id = " + SCD_ID.ToString(), " a.voy_iefg desc");
            foreach (DataRow item in dt.Rows)
            {
                UM_Voyages voyage = new UM_Voyages();
                if (item["CST_CSTM"] != null && !string.IsNullOrEmpty(item["CST_CSTM"].ToString()))
                {
                    voyage.CST_CSTM = item["CST_CSTM"].ToString();
                }
                if (item["VCM_CSTMCD"] != null && !string.IsNullOrEmpty(item["VCM_CSTMCD"].ToString()))
                {
                    voyage.VCM_CSTMCD = item["VCM_CSTMCD"].ToString();
                }

                if (item["CST_CSTMCD"] != null && !string.IsNullOrEmpty(item["CST_CSTMCD"].ToString()))
                {
                    voyage.CST_CSTMCD = item["CST_CSTMCD"].ToString();
                }
                if (item["CST_AGT_CSTM"] != null && !string.IsNullOrEmpty(item["CST_AGT_CSTM"].ToString()))
                {
                    voyage.CST_AGT_CSTM = item["CST_AGT_CSTM"].ToString();
                }

                if (item["CST_VCM_CSTM"] != null && !string.IsNullOrEmpty(item["CST_VCM_CSTM"].ToString()))
                {
                    voyage.CST_VCM_CSTM = item["CST_VCM_CSTM"].ToString();
                }
                if (item["SLN_NAME"] != null && !string.IsNullOrEmpty(item["SLN_NAME"].ToString()))
                {
                    voyage.SLN_NAME = item["SLN_NAME"].ToString();
                }
                if (item["VOY_ID"] != null && !string.IsNullOrEmpty(item["VOY_ID"].ToString()))
                {
                    voyage.VOY_ID = decimal.Parse(item["VOY_ID"].ToString());
                }
                if (item["VOY_IEFG"] != null && !string.IsNullOrEmpty(item["VOY_IEFG"].ToString()))
                {
                    voyage.VOY_IEFG = item["VOY_IEFG"].ToString();
                }
                if (item["VOY_LTONNAGE"] != null && !string.IsNullOrEmpty(item["VOY_LTONNAGE"].ToString()))
                {
                    voyage.VOY_LTONNAGE = decimal.Parse(item["VOY_LTONNAGE"].ToString());
                }
                if (item["VOY_PTONNAGE"] != null && !string.IsNullOrEmpty(item["VOY_PTONNAGE"].ToString()))
                {
                    voyage.VOY_PTONNAGE = decimal.Parse(item["VOY_PTONNAGE"].ToString());
                }
                if (item["VOY_SCD_ID"] != null && !string.IsNullOrEmpty(item["VOY_SCD_ID"].ToString()))
                {
                    voyage.VOY_SCD_ID = decimal.Parse(item["VOY_SCD_ID"].ToString());
                }
                if (item["VOY_VOYAGE"] != null && !string.IsNullOrEmpty(item["VOY_VOYAGE"].ToString()))
                {
                    voyage.VOY_VOYAGE = item["VOY_VOYAGE"].ToString();
                }
                if (item["VSL_ENNAME"] != null && !string.IsNullOrEmpty(item["VSL_ENNAME"].ToString()))
                {
                    voyage.VSL_ENNAME = item["VSL_ENNAME"].ToString();
                }
                if (item["VSL_CNNAME"] != null && !string.IsNullOrEmpty(item["VSL_CNNAME"].ToString()))
                {
                    voyage.VSL_CNNAME = item["VSL_CNNAME"].ToString();
                }

                if (item["VOY_SLN_ID"] != null && !string.IsNullOrEmpty(item["VOY_SLN_ID"].ToString()))
                {
                    voyage.VOY_SLN_ID = decimal.Parse(item["VOY_SLN_ID"].ToString());
                }
                if (item["FLT_SCHDUL"] != null && !string.IsNullOrEmpty(item["FLT_SCHDUL"].ToString()))
                {
                    voyage.FLT_SCHDUL = item["FLT_SCHDUL"].ToString();
                }
                if (item["VOY_INTRADE"] != null && !string.IsNullOrEmpty(item["VOY_INTRADE"].ToString()))
                {
                    voyage.VOY_INTRADE = item["VOY_INTRADE"].ToString();
                }
                if (item["VOY_FLT_ID"] != null && !string.IsNullOrEmpty(item["VOY_FLT_ID"].ToString()))
                {
                    voyage.VOY_FLT_ID = decimal.Parse(item["VOY_FLT_ID"].ToString());
                }
                

                list_Voyage.Add(voyage);
            }
            return list_Voyage;
        }

        /// <summary>
        /// 船期的集装箱箱量。
        /// </summary>
        /// <param name="SCD_ID"></param>
        /// <returns></returns>
        public List<UM_Voyage_Amounts> GetVoyageAmounts(decimal SCD_ID)
        {
            //BLL.BusinessDeal.StVoyagesManager stVoyage = new BLL.BusinessDeal.StVoyagesManager();
            //DataTable tableVoyage = stVoyage.GetVoyageBy_SCD_ID(SCD_ID.ToString());

            //string voy_ids = "";
            //if (tableVoyage != null && tableVoyage.Rows.Count > 0)
            //{
            //    if (tableVoyage.Rows.Count == 1)
            //    {
            //        voy_ids = tableVoyage.Rows[0]["VOY_ID"].ToString(); // voyInfos[0].VoyId.ToString();
            //    }
            //    else
            //    {
            //        voy_ids = tableVoyage.Rows[0]["VOY_ID"].ToString() + "," + tableVoyage.Rows[1]["VOY_ID"].ToString();
            //    }
            //    // this.SmartDataViewSource.SelectParameters["textWhere"].DefaultValue = " VAT_VOY_ID IN (" + voy_ids + ") ";
            //}


            List<UM_Voyage_Amounts> list_Voyage = new List<UM_Voyage_Amounts>();
            //Garlic.BLL.BusinessDeal.StVoyageAmountsManager ssm = new BLL.BusinessDeal.StVoyageAmountsManager();

            //DataTable dt = null;
            //if (!string.IsNullOrEmpty(voy_ids))
            //{
            //    dt = ssm.GetTable(" VAT_VOY_ID IN (" + voy_ids + ") ", string.Empty);
            //}
            //else
            //{
            //    dt = ssm.GetTable(string.Empty, string.Empty);
            //}
            //foreach (DataRow item in dt.Rows)
            //{
            //    UM_Voyage_Amounts amount = new UM_Voyage_Amounts();
            //    if (item["DTP_DNGGNM"] != null && !string.IsNullOrEmpty(item["DTP_DNGGNM"].ToString()))
            //    {
            //        amount.DTP_DNGGNM = item["DTP_DNGGNM"].ToString();
            //    }
            //    if (item["RV_MEANING"] != null && !string.IsNullOrEmpty(item["RV_MEANING"].ToString()))
            //    {
            //        amount.RV_MEANING = item["RV_MEANING"].ToString();
            //    }
            //    if (item["STS_REMARK"] != null && !string.IsNullOrEmpty(item["STS_REMARK"].ToString()))
            //    {
            //        amount.STS_REMARK = item["STS_REMARK"].ToString();
            //    }
            //    if (item["VAT_AMOUNT"] != null && !string.IsNullOrEmpty(item["VAT_AMOUNT"].ToString()))
            //    {
            //        amount.VAT_AMOUNT = Decimal.Parse(item["VAT_AMOUNT"].ToString());
            //    }
            //    if (item["VAT_CSZ_CSIZECD"] != null && !string.IsNullOrEmpty(item["VAT_CSZ_CSIZECD"].ToString()))
            //    {
            //        amount.VAT_CSZ_CSIZECD = item["VAT_CSZ_CSIZECD"].ToString();
            //    }
            //    if (item["VAT_RFFG"] != null && !string.IsNullOrEmpty(item["VAT_RFFG"].ToString()))
            //    {
            //        amount.VAT_RFFG = item["VAT_RFFG"].ToString();
            //    }
            //    if (item["VOY_IEFG"] != null && !string.IsNullOrEmpty(item["VOY_IEFG"].ToString()))
            //    {
            //        amount.VOY_IEFG = item["VOY_IEFG"].ToString();
            //    }
            //    list_Voyage.Add(amount);
            //}
            return list_Voyage;
        }

        //得到所有船名
        public List<ST_Vessels> GetAllVessels(string txtWhere, string txtOrder)
        {
            BLL.BusinessDeal.StVesselManager stVessel = new BLL.BusinessDeal.StVesselManager();
            DataTable tableVessel = stVessel.GetTable(txtWhere, txtOrder);
            List<ST_Vessels> list_Vessel = new List<ST_Vessels>();

            foreach (DataRow item in tableVessel.Rows)
            {
                ST_Vessels vess = new ST_Vessels();
                if (item["VSL_ID"] != null && !string.IsNullOrEmpty(item["VSL_ID"].ToString()))
                {
                    vess.VSL_ID = decimal.Parse(item["VSL_ID"].ToString());
                }
                if (item["VSL_CD"] != null && !string.IsNullOrEmpty(item["VSL_CD"].ToString()))
                {
                    vess.VSL_CD = item["VSL_CD"].ToString();
                }
                if (item["VSL_CNNAME"] != null && !string.IsNullOrEmpty(item["VSL_CNNAME"].ToString()))
                {
                    vess.VSL_CNNAME = item["VSL_CNNAME"].ToString();
                }
                if (item["VSL_ENNAME"] != null && !string.IsNullOrEmpty(item["VSL_ENNAME"].ToString()))
                {
                    vess.VSL_ENNAME = item["VSL_ENNAME"].ToString();
                }
                if (item["VSL_UNCODE"] != null && !string.IsNullOrEmpty(item["VSL_UNCODE"].ToString()))
                {
                    vess.VSL_UNCODE = item["VSL_UNCODE"].ToString();
                }

                list_Vessel.Add(vess);
            }
            return list_Vessel;
        }

        //得到所有码头
        public List<UM_Terminals> GetAllTerminalls()
        {
            BLL.BusinessDeal.StTerminalManager stTerminal = new BLL.BusinessDeal.StTerminalManager();
            DataTable tableTerminal = stTerminal.GetAllTerminal();
            List<UM_Terminals> list_Termial = new List<UM_Terminals>();
            foreach (DataRow item in tableTerminal.Rows)
            {
                UM_Terminals ter = new UM_Terminals();
                if (item["CST_ID"] != null && !string.IsNullOrEmpty(item["CST_ID"].ToString()))
                {
                    ter.CST_ID = int.Parse(item["CST_ID"].ToString());
                }
                if (item["CST_CSTM"] != null && !string.IsNullOrEmpty(item["CST_CSTM"].ToString()))
                {
                    ter.CST_CSTM = item["CST_CSTM"].ToString();
                }
                if (item["CST_CSTMNM"] != null && !string.IsNullOrEmpty(item["CST_CSTMNM"].ToString()))
                {
                    ter.CST_CSTMNM = item["CST_CSTMNM"].ToString();
                }
                list_Termial.Add(ter);
            }

            return list_Termial;
        }

        /// <summary>
        /// 得到所有配置表里的数据。
        /// </summary>
        /// <returns></returns>
        public List<UM_Ref_Code> GetRefCode(string txtWhere, string txtOrder)
        {
            BLL.BusinessDeal.StTerminalManager stTerminal = new BLL.BusinessDeal.StTerminalManager();
            DataTable tableTerminal = stTerminal.GetAllRef_Code(txtWhere, txtOrder);
            List<UM_Ref_Code> list_Termial = new List<UM_Ref_Code>();
            foreach (DataRow item in tableTerminal.Rows)
            {
                UM_Ref_Code ter = new UM_Ref_Code();
                if (item["RV_DOMAIN"] != null && !string.IsNullOrEmpty(item["RV_DOMAIN"].ToString()))
                {
                    ter.RV_DOMAIN = item["RV_DOMAIN"].ToString();
                }
                if (item["RV_LOW_VALUE"] != null && !string.IsNullOrEmpty(item["RV_LOW_VALUE"].ToString()))
                {
                    ter.RV_LOW_VALUE = item["RV_LOW_VALUE"].ToString();
                }
                if (item["RV_MEANING"] != null && !string.IsNullOrEmpty(item["RV_MEANING"].ToString()))
                {
                    ter.RV_MEANING = item["RV_MEANING"].ToString();
                }
                list_Termial.Add(ter);
            }
            return list_Termial;
        }
        /// <summary>
        /// 得到所有配置表里的数据 用于树状图
        /// </summary>
        /// <param name="stText"></param>
        /// <returns></returns>
        public List<UM_Ref_Code> GetUmRefCodeTreeView(string strWhere, string strOrder)
        {
            BLL.BusinessDeal.StTerminalManager stTerminal = new BLL.BusinessDeal.StTerminalManager();
            DataTable tableTerminal = stTerminal.GetDataTabelTreeView(strWhere, strOrder);
            List<UM_Ref_Code> list_Termial = new List<UM_Ref_Code>();
            foreach (DataRow item in tableTerminal.Rows)
            {
                UM_Ref_Code ter = new UM_Ref_Code();
                if (item["RV_DOMAIN"] != null && !string.IsNullOrEmpty(item["RV_DOMAIN"].ToString()))
                {
                    ter.RV_DOMAIN = item["RV_DOMAIN"].ToString();
                }
                if (item["RV_LOW_VALUE"] != null && !string.IsNullOrEmpty(item["RV_LOW_VALUE"].ToString()))
                {
                    ter.RV_LOW_VALUE = item["RV_LOW_VALUE"].ToString();
                }
                if (item["RV_MEANING"] != null && !string.IsNullOrEmpty(item["RV_MEANING"].ToString()))
                {
                    ter.RV_MEANING = item["RV_MEANING"].ToString();
                }
                if (item["RV_EDICODE"] != null && !string.IsNullOrEmpty(item["RV_EDICODE"].ToString()))
                {
                    ter.RV_EDICODE = item["RV_EDICODE"].ToString();
                }
                list_Termial.Add(ter);
            }
            return list_Termial;
        }

        /// <summary>
        /// 得到所有停靠港.
        /// </summary>
        /// <param name="txtWhere"></param>
        /// <param name="txtOrder"></param>
        /// <returns></returns>
        public List<UM_Ports> GetAllPort(string txtWhere, string txtOrder)
        {
            BLL.BusinessDeal.StTerminalManager stTerminal = new BLL.BusinessDeal.StTerminalManager();
            DataTable tableTerminal = stTerminal.GetAllPort(txtWhere, txtOrder);
            List<UM_Ports> list_Termial = new List<UM_Ports>();
            foreach (DataRow item in tableTerminal.Rows)
            {
                UM_Ports ter = new UM_Ports();
                if (item["POT_ID"] != null && !string.IsNullOrEmpty(item["POT_ID"].ToString()))
                {
                    ter.POT_ID = decimal.Parse(item["POT_ID"].ToString());
                }
                if (item["POT_PORTCD"] != null && !string.IsNullOrEmpty(item["POT_PORTCD"].ToString()))
                {
                    ter.POT_PORTCD = item["POT_PORTCD"].ToString();
                }
                if (item["POT_PORTENGNM"] != null && !string.IsNullOrEmpty(item["POT_PORTENGNM"].ToString()))
                {
                    ter.POT_PORTENGNM = item["POT_PORTENGNM"].ToString();
                }
                if (item["POT_PORTLOCNNM"] != null && !string.IsNullOrEmpty(item["POT_PORTLOCNNM"].ToString()))
                {
                    ter.POT_PORTLOCNNM = item["POT_PORTLOCNNM"].ToString();
                }
                list_Termial.Add(ter);
            }
            return list_Termial;
        }

        /// <summary>
        /// 新增船期的数据。
        /// </summary>
        /// <param name="user_id"></param>
        /// <param name="cnname"></param>
        /// <param name="enname"></param>
        /// <param name="ivoyage"></param>
        /// <param name="evoyage"></param>
        /// <param name="eta"></param>
        /// <param name="etd"></param>
        /// <param name="state"></param>
        /// <param name="ter_id"></param>
        /// <param name="culoc"></param>
        /// <param name="pilotage"></param>
        /// <param name="fid"></param>
        /// <param name="nid"></param>
        /// <param name="sln_id"></param>
        /// <param name="flt_id"></param>
        /// <returns></returns>
        public string InsertToTable_Schedule(string user_id, string cnname, string enname, string ivoyage, string evoyage, DateTime eta, DateTime etd, string state, string ter_id, string culoc, string pilotage, string fid, string nid, string sln_id, string flt_id, string vsl_code)
        {
            BLL.BusinessDeal.StSchedulesManager ssm = new BLL.BusinessDeal.StSchedulesManager();
            return ssm.InsertToTable(user_id, cnname, enname, ivoyage, evoyage, eta, etd, state, ter_id, culoc, pilotage, fid, nid, sln_id, flt_id, vsl_code);
        }

        /// <summary>
        /// 删除船期的数据。
        /// </summary>
        /// <param name="scd_id"></param>
        public string DeleteBySCD_ID(string scd_id)
        {
            BLL.BusinessDeal.StSchedulesManager ssm = new BLL.BusinessDeal.StSchedulesManager();
            return ssm.DeleteBySCD_ID(scd_id);
        }


        /// <summary>
        /// 根据scd_id查得船期记录。
        /// </summary>
        /// <param name="scd_id"></param>
        /// <returns></returns>
        public ST_Schedules GetScheduleBy_SCD_ID(string scd_id)
        {
            BLL.BusinessDeal.StSchedulesManager ssm = new BLL.BusinessDeal.StSchedulesManager();
            DataTable table = ssm.SelectTableBySCD_ID(scd_id);
            ST_Schedules schedule = null;
            foreach (DataRow item in table.Rows)
            {
                schedule = new ST_Schedules();
                if (item["SCD_ARCHIVETM"] != null && !string.IsNullOrEmpty(item["SCD_ARCHIVETM"].ToString().Trim()))
                {
                    schedule.SCD_ARCHIVETM = DateTime.Parse(item["SCD_ARCHIVETM"].ToString());
                }
                if (item["SCD_ATA"] != null && !string.IsNullOrEmpty(item["SCD_ATA"].ToString().Trim()))
                {
                    schedule.SCD_ATA = DateTime.Parse(item["SCD_ATA"].ToString());
                }
                if (item["SCD_ATD"] != null && !string.IsNullOrEmpty(item["SCD_ATD"].ToString().Trim()))
                {
                    schedule.SCD_ATD = DateTime.Parse(item["SCD_ATD"].ToString());
                }
                if (item["SCD_CULOC"] != null && !string.IsNullOrEmpty(item["SCD_CULOC"].ToString().Trim()))
                {
                    schedule.SCD_CULOC = item["SCD_CULOC"].ToString();
                }
                if (item["SCD_DUMMY"] != null && !string.IsNullOrEmpty(item["SCD_DUMMY"].ToString().Trim()))
                {
                    schedule.SCD_DUMMY = item["SCD_DUMMY"].ToString();
                }
                if (item["SCD_EMBARGOFG"] != null && !string.IsNullOrEmpty(item["SCD_EMBARGOFG"].ToString().Trim()))
                {
                    schedule.SCD_EMBARGOFG = item["SCD_EMBARGOFG"].ToString();
                }
                if (item["SCD_ETA"] != null && !string.IsNullOrEmpty(item["SCD_ETA"].ToString().Trim()))
                {
                    schedule.SCD_ETA = DateTime.Parse(item["SCD_ETA"].ToString());
                }
                if (item["SCD_ETD"] != null && !string.IsNullOrEmpty(item["SCD_ETD"].ToString().Trim()))
                {
                    schedule.SCD_ETD = DateTime.Parse(item["SCD_ETD"].ToString());
                }
                if (item["SCD_EVOYAGE"] != null && !string.IsNullOrEmpty(item["SCD_EVOYAGE"].ToString().Trim()))
                {
                    schedule.SCD_EVOYAGE = item["SCD_EVOYAGE"].ToString();
                }
                if (item["SCD_FIXSCDSHPFG"] != null && !string.IsNullOrEmpty(item["SCD_FIXSCDSHPFG"].ToString().Trim()))
                {
                    schedule.SCD_FIXSCDSHPFG = item["SCD_FIXSCDSHPFG"].ToString();
                }
                if (item["SCD_ID"] != null && !string.IsNullOrEmpty(item["SCD_ID"].ToString().Trim()))
                {
                    schedule.SCD_ID = decimal.Parse(item["SCD_ID"].ToString());
                }
                if (item["SCD_INSERTDT"] != null && !string.IsNullOrEmpty(item["SCD_INSERTDT"].ToString().Trim()))
                {
                    schedule.SCD_INSERTDT = DateTime.Parse(item["SCD_INSERTDT"].ToString());
                }
                if (item["SCD_INSERTUSER"] != null && !string.IsNullOrEmpty(item["SCD_INSERTUSER"].ToString().Trim()))
                {
                    schedule.SCD_INSERTUSER = item["SCD_INSERTUSER"].ToString();
                }
                if (item["SCD_IVOYAGE"] != null && !string.IsNullOrEmpty(item["SCD_IVOYAGE"].ToString().Trim()))
                {
                    schedule.SCD_IVOYAGE = item["SCD_IVOYAGE"].ToString();
                }
                if (item["SCD_LSTUPDDT"] != null && !string.IsNullOrEmpty(item["SCD_LSTUPDDT"].ToString().Trim()))
                {
                    schedule.SCD_LSTUPDDT = DateTime.Parse(item["SCD_LSTUPDDT"].ToString());
                }
                if (item["SCD_LSTUPUSER"] != null && !string.IsNullOrEmpty(item["SCD_LSTUPUSER"].ToString().Trim()))
                {
                    schedule.SCD_LSTUPUSER = item["SCD_LSTUPUSER"].ToString();
                }
                if (item["SCD_MADEMODE"] != null && !string.IsNullOrEmpty(item["SCD_MADEMODE"].ToString().Trim()))
                {
                    schedule.SCD_MADEMODE = item["SCD_MADEMODE"].ToString();
                }
                if (item["SCD_PARTITIONNM"] != null && !string.IsNullOrEmpty(item["SCD_PARTITIONNM"].ToString().Trim()))
                {
                    schedule.SCD_PARTITIONNM = item["SCD_PARTITIONNM"].ToString();
                }
                if (item["SCD_PILOTAGE"] != null && !string.IsNullOrEmpty(item["SCD_PILOTAGE"].ToString().Trim()))
                {
                    schedule.SCD_PILOTAGE = item["SCD_PILOTAGE"].ToString();
                }
                if (item["SCD_POT_FID"] != null && !string.IsNullOrEmpty(item["SCD_POT_FID"].ToString().Trim()))
                {
                    schedule.SCD_POT_FID = decimal.Parse(item["SCD_POT_FID"].ToString());
                }
                if (item["SCD_POT_NID"] != null && !string.IsNullOrEmpty(item["SCD_POT_NID"].ToString().Trim()))
                {
                    schedule.SCD_POT_NID = decimal.Parse(item["SCD_POT_NID"].ToString());
                }
                if (item["SCD_RCVEDDT"] != null && !string.IsNullOrEmpty(item["SCD_RCVEDDT"].ToString().Trim()))
                {
                    schedule.SCD_RCVEDDT = DateTime.Parse(item["SCD_RCVEDDT"].ToString());
                }
                if (item["SCD_RCVSTDT"] != null && !string.IsNullOrEmpty(item["SCD_RCVSTDT"].ToString().Trim()))
                {
                    schedule.SCD_RCVSTDT = DateTime.Parse(item["SCD_RCVSTDT"].ToString());
                }
                if (item["SCD_REMARK"] != null && !string.IsNullOrEmpty(item["SCD_REMARK"].ToString().Trim()))
                {
                    schedule.SCD_REMARK = item["SCD_REMARK"].ToString();
                }
                if (item["SCD_SHUTTLEBUS"] != null && !string.IsNullOrEmpty(item["SCD_SHUTTLEBUS"].ToString().Trim()))
                {
                    schedule.SCD_SHUTTLEBUS = item["SCD_SHUTTLEBUS"].ToString();
                }
                if (item["SCD_SLN_ID"] != null && !string.IsNullOrEmpty(item["SCD_SLN_ID"].ToString().Trim()))
                {
                    schedule.SCD_SLN_ID = decimal.Parse(item["SCD_SLN_ID"].ToString());
                }
                if (item["SCD_SN"] != null && !string.IsNullOrEmpty(item["SCD_SN"].ToString().Trim()))
                {
                    schedule.SCD_SN = item["SCD_SN"].ToString();
                }
                if (item["SCD_STATUS"] != null && !string.IsNullOrEmpty(item["SCD_STATUS"].ToString().Trim()))
                {
                    schedule.SCD_STATUS = item["SCD_STATUS"].ToString();
                }
                if (item["SCD_TER_CST_ID"] != null && !string.IsNullOrEmpty(item["SCD_TER_CST_ID"].ToString().Trim()))
                {
                    schedule.SCD_TER_CST_ID = decimal.Parse(item["SCD_TER_CST_ID"].ToString());
                }
                if (item["SCD_VSL_ID"] != null && !string.IsNullOrEmpty(item["SCD_VSL_ID"].ToString().Trim()))
                {
                    schedule.SCD_VSL_ID = decimal.Parse(item["SCD_VSL_ID"].ToString());
                }
            }
            return schedule;
        }

        /// <summary>
        ///  根据sln_id查得服务航线记录.
        /// </summary>
        /// <param name="sln_id"></param>
        /// <returns></returns>
        public ST_SERVICE_LINES GetService_LinesBySLN_ID(string sln_id)
        {
            BLL.BusinessDeal.StSchedulesManager ssm = new BLL.BusinessDeal.StSchedulesManager();
            DataTable table = ssm.SelectService_Line(sln_id);
            ST_SERVICE_LINES service_line = null;
            foreach (DataRow item in table.Rows)
            {
                service_line = new ST_SERVICE_LINES();
                if (item["SLN_AVLFG"] != null && !string.IsNullOrEmpty(item["SLN_AVLFG"].ToString().Trim()))
                {
                    service_line.SLN_AVLFG = item["SLN_AVLFG"].ToString();
                }
                if (item["SLN_BERTHNUM"] != null && !string.IsNullOrEmpty(item["SLN_BERTHNUM"].ToString().Trim()))
                {
                    service_line.SLN_BERTHNUM = decimal.Parse(item["SLN_BERTHNUM"].ToString());
                }
                if (item["SLN_CLOSEFG"] != null && !string.IsNullOrEmpty(item["SLN_CLOSEFG"].ToString().Trim()))
                {
                    service_line.SLN_CLOSEFG = item["SLN_CLOSEFG"].ToString();
                }
                if (item["SLN_CODE"] != null && !string.IsNullOrEmpty(item["SLN_CODE"].ToString().Trim()))
                {
                    service_line.SLN_CODE = item["SLN_CODE"].ToString();
                }
                if (item["SLN_CST_AGT_ID"] != null && !string.IsNullOrEmpty(item["SLN_CST_AGT_ID"].ToString().Trim()))
                {
                    service_line.SLN_CST_AGT_ID = decimal.Parse(item["SLN_CST_AGT_ID"].ToString());
                }
                if (item["SLN_CST_VCM_ID"] != null && !string.IsNullOrEmpty(item["SLN_CST_VCM_ID"].ToString().Trim()))
                {
                    service_line.SLN_CST_VCM_ID = decimal.Parse(item["SLN_CST_VCM_ID"].ToString());
                }
                if (item["SLN_EMPNO"] != null && !string.IsNullOrEmpty(item["SLN_EMPNO"].ToString().Trim()))
                {
                    service_line.SLN_EMPNO = item["SLN_EMPNO"].ToString();
                }
                if (item["SLN_FIXSCDSHP"] != null && !string.IsNullOrEmpty(item["SLN_FIXSCDSHP"].ToString().Trim()))
                {
                    service_line.SLN_FIXSCDSHP = item["SLN_FIXSCDSHP"].ToString();
                }
                if (item["SLN_ID"] != null && !string.IsNullOrEmpty(item["SLN_ID"].ToString().Trim()))
                {
                    service_line.SLN_ID = decimal.Parse(item["SLN_ID"].ToString());
                }
                if (item["SLN_INSERTDT"] != null && !string.IsNullOrEmpty(item["SLN_INSERTDT"].ToString().Trim()))
                {
                    service_line.SLN_INSERTDT = DateTime.Parse(item["SLN_INSERTDT"].ToString());
                }
                if (item["SLN_INSERTUSER"] != null && !string.IsNullOrEmpty(item["SLN_INSERTUSER"].ToString().Trim()))
                {
                    service_line.SLN_INSERTUSER = item["SLN_INSERTUSER"].ToString();
                }
                if (item["SLN_LSTUPDDT"] != null && !string.IsNullOrEmpty(item["SLN_LSTUPDDT"].ToString().Trim()))
                {
                    service_line.SLN_LSTUPDDT = DateTime.Parse(item["SLN_LSTUPDDT"].ToString());
                }
                if (item["SLN_LSTUPUSER"] != null && !string.IsNullOrEmpty(item["SLN_LSTUPUSER"].ToString().Trim()))
                {
                    service_line.SLN_LSTUPUSER = item["SLN_LSTUPUSER"].ToString();
                }
                if (item["SLN_MNGCHRCTR"] != null && !string.IsNullOrEmpty(item["SLN_MNGCHRCTR"].ToString().Trim()))
                {
                    service_line.SLN_MNGCHRCTR = item["SLN_MNGCHRCTR"].ToString();
                }
                if (item["SLN_NAME"] != null && !string.IsNullOrEmpty(item["SLN_NAME"].ToString().Trim()))
                {
                    service_line.SLN_NAME = item["SLN_NAME"].ToString();
                }
                if (item["SLN_PAYYERTP"] != null && !string.IsNullOrEmpty(item["SLN_PAYYERTP"].ToString().Trim()))
                {
                    service_line.SLN_PAYYERTP = item["SLN_PAYYERTP"].ToString();
                }
                if (item["SLN_PREDAYS"] != null && !string.IsNullOrEmpty(item["SLN_PREDAYS"].ToString().Trim()))
                {
                    service_line.SLN_PREDAYS = decimal.Parse(item["SLN_PREDAYS"].ToString());
                }
                if (item["SLN_PRETIME"] != null && !string.IsNullOrEmpty(item["SLN_PRETIME"].ToString().Trim()))
                {
                    service_line.SLN_PRETIME = DateTime.Parse(item["SLN_PRETIME"].ToString());
                }
                if (item["SLN_PRT"] != null && !string.IsNullOrEmpty(item["SLN_PRT"].ToString().Trim()))
                {
                    service_line.SLN_PRT = item["SLN_PRT"].ToString();
                }
                if (item["SLN_PRT_ID"] != null && !string.IsNullOrEmpty(item["SLN_PRT_ID"].ToString().Trim()))
                {
                    service_line.SLN_PRT_ID = decimal.Parse(item["SLN_PRT_ID"].ToString());
                }
                if (item["SLN_REMARK"] != null && !string.IsNullOrEmpty(item["SLN_REMARK"].ToString().Trim()))
                {
                    service_line.SLN_REMARK = item["SLN_REMARK"].ToString();
                }
                if (item["SLN_SCHDUL"] != null && !string.IsNullOrEmpty(item["SLN_SCHDUL"].ToString().Trim()))
                {
                    service_line.SLN_SCHDUL = item["SLN_SCHDUL"].ToString();
                }
                if (item["SLN_SRT_ID"] != null && !string.IsNullOrEmpty(item["SLN_SRT_ID"].ToString().Trim()))
                {
                    service_line.SLN_SRT_ID = decimal.Parse(item["SLN_SRT_ID"].ToString());
                }
                if (item["SLN_STOPTIME"] != null && !string.IsNullOrEmpty(item["SLN_STOPTIME"].ToString().Trim()))
                {
                    service_line.SLN_STOPTIME = DateTime.Parse(item["SLN_STOPTIME"].ToString());
                }
                if (item["SLN_TER_CST_ID"] != null && !string.IsNullOrEmpty(item["SLN_TER_CST_ID"].ToString().Trim()))
                {
                    service_line.SLN_TER_CST_ID = decimal.Parse(item["SLN_TER_CST_ID"].ToString());
                }
            }
            return service_line;
        }

        /// <summary>
        /// 更新班期表。
        /// </summary>
        /// <param name="scd_id"></param>
        /// <param name="user_id"></param>
        /// <param name="cnname"></param>
        /// <param name="enname"></param>
        /// <param name="ivoyage"></param>
        /// <param name="evoyage"></param>
        /// <param name="eta"></param>
        /// <param name="etd"></param>
        /// <param name="state"></param>
        /// <param name="ter_id"></param>
        /// <param name="culoc"></param>
        /// <param name="pilotage"></param>
        /// <param name="fid"></param>
        /// <param name="nid"></param>
        /// <param name="flt_id"></param>
        /// <returns></returns>
        public string UpdateSchedule(string scd_id, string user_id, string cnname, string enname, string ivoyage, string evoyage, DateTime eta, DateTime etd, string state, string ter_id, string culoc, string pilotage, string fid, string nid, string flt_id,string vsl_code)
        {
            BLL.BusinessDeal.StSchedulesManager ssm = new BLL.BusinessDeal.StSchedulesManager();
            return ssm.UpdateSchedule(scd_id, user_id, cnname, enname, ivoyage, evoyage, eta, etd, state, ter_id, culoc, pilotage, fid, nid, flt_id,vsl_code);
        }
        /// <summary>
        /// 新增  修改 靠泊,P_Operation_Type为1是新增，2是修改。
        /// </summary>
        /// <param name="scd_id"></param>
        /// <param name="user_id"></param>
        /// <param name="cnname"></param>
        /// <param name="enname"></param>
        /// <param name="ivoyage"></param>
        /// <param name="evoyage"></param>
        /// <param name="eta"></param>
        /// <param name="etd"></param>
        /// <param name="state"></param>
        /// <param name="ter_id"></param>
        /// <returns></returns>
        public string InsertUpdateVesselBerth(int P_Operation_Type, string p_SCD_ID, DateTime P_VBT_PBTHDT, DateTime P_VBT_PDPTDT,
                   string P_VBT_PBTHDRAFT, string P_VBT_PBTHDRAFT_P, string P_VBT_PBTHDRAFT_A, string P_VBT_PDPTDRAFT
                 , string P_VBT_PDPTDRAFT_P, string vVBT_PDPTDRAFT_A, string P_VBT_TER_ID, string P_USER_ID, string VBT_ID, string P_VBT_LDUNLDFG)
        {
            BLL.BusinessDeal.StVesselBerthManager mss = new BLL.BusinessDeal.StVesselBerthManager();
            return mss.InsertUpdateToTable(P_Operation_Type, p_SCD_ID, P_VBT_PBTHDT, P_VBT_PDPTDT, P_VBT_PBTHDRAFT, P_VBT_PBTHDRAFT_P, P_VBT_PBTHDRAFT_A,
                  P_VBT_PDPTDRAFT, P_VBT_PDPTDRAFT_P, vVBT_PDPTDRAFT_A, P_VBT_TER_ID, P_USER_ID, VBT_ID, P_VBT_LDUNLDFG);

        }

        /// <summary>
        /// 新增 修改 航次 P_Operation_Type为1是新增，2是修改。
        /// </summary>
        /// <param name="P_Operation_Code"></param>
        /// <param name="P_VOY_ID"></param>
        /// <param name="P_User_ID"></param>
        /// <param name="P_VOY_IEFG"></param>
        /// <param name="P_VOY_SLN_ID"></param>
        /// <param name="P_SCD_ID"></param>
        /// <param name="P_VOY_FLT_ID"></param>
        /// <param name="P_VOY_VOYAGE"></param>
        /// <param name="P_VOY_INTRADE"></param>
        /// <returns></returns>
        public string InsertUpdateProcessVoyage(int P_Operation_Code, int P_VOY_ID, int P_User_ID,
            string P_VOY_IEFG, int P_VOY_SLN_ID, int P_SCD_ID, int P_VOY_FLT_ID, string P_VOY_VOYAGE,
            string P_VOY_INTRADE)
        {
            BLL.BusinessDeal.StSpProcessVoyageManager mss = new BLL.BusinessDeal.StSpProcessVoyageManager();
            return mss.InsertUpdateToTable(P_Operation_Code, P_VOY_ID, P_User_ID, P_VOY_IEFG, P_VOY_SLN_ID,
                      P_SCD_ID, P_VOY_FLT_ID, P_VOY_VOYAGE, P_VOY_INTRADE);
        }
        /// <summary>
        /// 新增 修改 箱表 P_Operation_Type为1是新增，2是修改。
        /// </summary>
        /// <param name="P_Operation_Code"></param>
        /// <param name="P_VOY_ID"></param>
        /// <param name="P_CSZ_CSIZECD"></param>
        /// <param name="P_STS_CSTATUSCD"></param>
        /// <param name="P_DNGFG"></param>
        /// <param name="P_OVLMTCD"></param>
        /// <param name="P_RFFG"></param>
        /// <param name="P_AMOUNT"></param>
        /// <param name="P_USER_ID"></param>
        /// <param name="P_EFFG"></param>
        /// <param name="P_VAT_ID"></param>
        /// <returns></returns>
        public string InsertUpdateProcessCTNAmount(int P_Operation_Type, string P_VOY_ID, string P_CSZ_CSIZECD,
           string P_STS_CSTATUSCD, string P_DNGFG, string P_OVLMTCD, string P_RFFG, string P_AMOUNT, string P_USER_ID
            , string P_EFFG, string P_SCD_ID, string P_VAT_ID)
        {
            BLL.BusinessDeal.StSpProcessCTNAmountManager mss = new BLL.BusinessDeal.StSpProcessCTNAmountManager();
            return mss.InsertUpdateToTable(P_Operation_Type, P_VOY_ID, P_CSZ_CSIZECD, P_STS_CSTATUSCD, P_DNGFG,
                      P_OVLMTCD, P_RFFG, P_AMOUNT, P_USER_ID, P_EFFG, P_VAT_ID, P_SCD_ID);
        }
        /// <summary>
        /// 增加 修改 货物表 P_Operation_Type为1是新增，2是修改。
        /// </summary>
        /// <param name="P_Operation_Type"></param>
        /// <param name="P_VOY_ID"></param>
        /// <param name="P_VAG_GTYPECD"></param>
        /// <param name="P_VAG_PKG"></param>
        /// <param name="P_VAG_TON"></param>
        /// <param name="P_VAG_VOL"></param>
        /// <param name="P_VAG_REMARK"></param>
        /// <param name="P_USER_ID"></param>
        /// <returns></returns>
        public string InsertUpdateProcessCargoAmount(int P_Operation_Type, string P_VOY_ID, string vag_id, string P_VAG_GTYPECD,
           string P_VAG_PKG, string P_VAG_TON, string P_VAG_VOL, string P_VAG_REMARK, string P_USER_ID, string P_SCD_ID)
        {
            BLL.BusinessDeal.StSpProcessCargoAmountManager mss = new BLL.BusinessDeal.StSpProcessCargoAmountManager();
            return mss.InsertUpdateToTable(P_Operation_Type, P_VOY_ID, vag_id, P_VAG_GTYPECD,
            P_VAG_PKG, P_VAG_TON, P_VAG_VOL, P_VAG_REMARK, P_USER_ID, P_SCD_ID);
        }

        /// <summary>
        /// 获取箱尺寸
        /// </summary>
        /// <returns></returns>
        public List<ST_Container_Sizes> GetSTContainerSizes()
        {
            BLL.BusinessDeal.StContainerSizesManager mss = new BLL.BusinessDeal.StContainerSizesManager();
            DataTable tableSTContainerSizes = mss.GetTable();

            List<ST_Container_Sizes> containerList = new List<ST_Container_Sizes>();

            foreach (DataRow item in tableSTContainerSizes.Rows)
            {
                ST_Container_Sizes st_sizes = new ST_Container_Sizes();
                if (item["CSZ_CSIZECD"] != null && !string.IsNullOrEmpty(item["CSZ_CSIZECD"].ToString().Trim()))
                {
                    st_sizes.CSZ_CSIZECD = item["CSZ_CSIZECD"].ToString();
                }
                if (item["CSZ_CSIZENM"] != null && !string.IsNullOrEmpty(item["CSZ_CSIZENM"].ToString().Trim()))
                {
                    st_sizes.CSZ_CSIZENM = item["CSZ_CSIZENM"].ToString();
                }
                if (item["CSZ_BELONGSIZE"] != null && !string.IsNullOrEmpty(item["CSZ_BELONGSIZE"].ToString().Trim()))
                {
                    st_sizes.CSZ_BELONGSIZE = item["CSZ_BELONGSIZE"].ToString();
                }

                containerList.Add(st_sizes);
            }
            return containerList;
        }
        /// <summary>
        /// 获取箱数量
        /// </summary>
        /// <returns></returns>
        public List<ST_Container_Status> GetSTContainerStatus(string txtWhere,string txtOrder)
        {
            BLL.BusinessDeal.StContainerStatusManager mss = new BLL.BusinessDeal.StContainerStatusManager();
            DataTable tableSTContainerSizes = mss.GetTable(txtWhere, txtOrder);

            List<ST_Container_Status> containerList = new List<ST_Container_Status>();

            foreach (DataRow item in tableSTContainerSizes.Rows)
            {
                ST_Container_Status st_status = new ST_Container_Status();
                if (item["STS_CSTATUSCD"] != null && !string.IsNullOrEmpty(item["STS_CSTATUSCD"].ToString().Trim()))
                {
                    st_status.STS_CSTATUSCD = item["STS_CSTATUSCD"].ToString();
                }
                if (item["STS_REMARK"] != null && !string.IsNullOrEmpty(item["STS_REMARK"].ToString().Trim()))
                {
                    st_status.STS_REMARK = item["STS_REMARK"].ToString();
                }
                containerList.Add(st_status);
            }

            return containerList;
        }

        /// <summary>
        /// 获取危险品货物集合
        /// </summary>
        /// <returns></returns>
        public List<ST_Dangerous_Cargo_Codes> GetSTDangerousCargoCodes()
        {
            BLL.BusinessDeal.StDangerousCargoCodesManager mss = new BLL.BusinessDeal.StDangerousCargoCodesManager();
            DataTable tableSTContainerSizes = mss.GetTable();

            List<ST_Dangerous_Cargo_Codes> containerList = new List<ST_Dangerous_Cargo_Codes>();

            foreach (DataRow item in tableSTContainerSizes.Rows)
            {
                ST_Dangerous_Cargo_Codes st_status = new ST_Dangerous_Cargo_Codes();
                if (item["DTP_DNGGCD"] != null && !string.IsNullOrEmpty(item["DTP_DNGGCD"].ToString().Trim()))
                {
                    st_status.DTP_DNGGCD = item["DTP_DNGGCD"].ToString();
                }

                if (item["DTP_DNGGNM"] != null && !string.IsNullOrEmpty(item["DTP_DNGGNM"].ToString().Trim()))
                {
                    st_status.DTP_DNGGNM = item["DTP_DNGGNM"].ToString();
                }
                containerList.Add(st_status);
            }

            return containerList;
        }

        /// <summary>
        /// 航次的集装箱箱量。
        /// </summary>
        /// <param name="txtWhere"></param>
        /// <returns></returns>
        public List<UM_Voyage_Amounts> GetVoyageAmounts_CTNAmount(string txtWhere)
        {

            BLL.BusinessDeal.StSpProcessCTNAmountManager stVoyage = new BLL.BusinessDeal.StSpProcessCTNAmountManager();
            DataTable tableVoyageAmount = stVoyage.GetTable(txtWhere, string.Empty);

            List<UM_Voyage_Amounts> list_Voyage = new List<UM_Voyage_Amounts>();

            foreach (DataRow item in tableVoyageAmount.Rows)
            {
                UM_Voyage_Amounts amount = new UM_Voyage_Amounts();
                if (item["CSZ_CSIZENM"] != null && !string.IsNullOrEmpty(item["CSZ_CSIZENM"].ToString()))
                {
                    amount.CSZ_CSIZENM = item["CSZ_CSIZENM"].ToString();
                }
                if (item["RV_MEANING"] != null && !string.IsNullOrEmpty(item["RV_MEANING"].ToString()))
                {
                    amount.RV_MEANING = item["RV_MEANING"].ToString();
                }
                if (item["VAT_AMOUNT"] != null && !string.IsNullOrEmpty(item["VAT_AMOUNT"].ToString()))
                {
                    amount.VAT_AMOUNT = decimal.Parse(item["VAT_AMOUNT"].ToString());
                }
                if (item["VAT_CSZ_CSIZECD"] != null && !string.IsNullOrEmpty(item["VAT_CSZ_CSIZECD"].ToString()))
                {
                    amount.VAT_CSZ_CSIZECD = item["VAT_CSZ_CSIZECD"].ToString();
                }
                if (item["VAT_DNGFG"] != null && !string.IsNullOrEmpty(item["VAT_DNGFG"].ToString()))
                {
                    amount.VAT_DNGFG = item["VAT_DNGFG"].ToString();
                }
                if (item["VAT_ID"] != null && !string.IsNullOrEmpty(item["VAT_ID"].ToString()))
                {
                    amount.VAT_ID = decimal.Parse(item["VAT_ID"].ToString());
                }
                if (item["VAT_OVLMTCD"] != null && !string.IsNullOrEmpty(item["VAT_OVLMTCD"].ToString()))
                {
                    amount.VAT_OVLMTCD = item["VAT_OVLMTCD"].ToString();
                }
                if (item["VAT_RFFG"] != null && !string.IsNullOrEmpty(item["VAT_RFFG"].ToString()))
                {
                    amount.VAT_RFFG = item["VAT_RFFG"].ToString();
                }
                if (item["VAT_STS_CSTATUSCD"] != null && !string.IsNullOrEmpty(item["VAT_STS_CSTATUSCD"].ToString()))
                {
                    amount.VAT_STS_CSTATUSCD = item["VAT_STS_CSTATUSCD"].ToString();
                }
                if (item["VAT_VOY_ID"] != null && !string.IsNullOrEmpty(item["VAT_VOY_ID"].ToString()))
                {
                    amount.VAT_VOY_ID = decimal.Parse(item["VAT_VOY_ID"].ToString());
                }
                if (item["VAT_EFFG"] != null && !string.IsNullOrEmpty(item["VAT_EFFG"].ToString()))
                {
                    amount.VAT_EFFG = item["VAT_EFFG"].ToString();
                }
                list_Voyage.Add(amount);
            }
            return list_Voyage;
        }

        /// <summary>
        /// 批量删除集装箱  true 删除成功，false 删除失败
        /// </summary>
        /// <param name="mList"></param>
        /// <returns></returns>
        public bool DeleteStVoyageAmounts(List<string> mList)
        {
            BLL.BusinessDeal.StVoyageAmountsManager mss = new BLL.BusinessDeal.StVoyageAmountsManager();
            return mss.DeleteTable(mList);
        }

        /// <summary>
        /// 批量删除散货  true 删除成功，false 删除失败
        /// </summary>
        /// <param name="mList"></param>
        /// <returns></returns>
        public bool DeleteProcessCargomount(List<string> mList)
        {
            BLL.BusinessDeal.StSpProcessCargoAmountManager mss = new BLL.BusinessDeal.StSpProcessCargoAmountManager();
            return mss.DeleteProcessCargomount(mList);
        }

        /// <summary>
        /// 得到散货箱量
        /// </summary>
        /// <param name="strWhere">条件</param>
        /// <param name="strOrder">排序</param>
        /// <returns></returns>
        public List<ST_VOYAGE_CARGO_AMOUNTS> GetStVoyageCargoAmounts(string strWhere, string strOrder)
        {
            BLL.BusinessDeal.StSpProcessCargoAmountManager mss = new BLL.BusinessDeal.StSpProcessCargoAmountManager();
            DataTable tableVoyageCargoAmounts = mss.GetTable(strWhere, strOrder);

            List<ST_VOYAGE_CARGO_AMOUNTS> voyage = new List<ST_VOYAGE_CARGO_AMOUNTS>();

            foreach (DataRow item in tableVoyageCargoAmounts.Rows)
            {
                ST_VOYAGE_CARGO_AMOUNTS amount = new ST_VOYAGE_CARGO_AMOUNTS();
                if (item["VAG_ID"] != null && !string.IsNullOrEmpty(item["VAG_ID"].ToString()))
                {
                    amount.VAG_ID = decimal.Parse(item["VAG_ID"].ToString());
                }
                if (item["VAG_VOY_ID"] != null && !string.IsNullOrEmpty(item["VAG_VOY_ID"].ToString()))
                {
                    amount.VAG_VOY_ID = decimal.Parse(item["VAG_VOY_ID"].ToString());
                }
                if (item["VAG_GTYPECD"] != null && !string.IsNullOrEmpty(item["VAG_GTYPECD"].ToString()))
                {
                    amount.VAG_GTYPECD = item["VAG_GTYPECD"].ToString();
                }
                if (item["RV_MEANING"] != null && !string.IsNullOrEmpty(item["RV_MEANING"].ToString()))
                {
                    amount.RV_MEANING = item["RV_MEANING"].ToString();
                }
                if (item["VAG_PKG"] != null && !string.IsNullOrEmpty(item["VAG_PKG"].ToString()))
                {
                    amount.VAG_PKG = decimal.Parse(item["VAG_PKG"].ToString());
                }
                if (item["VAG_TON"] != null && !string.IsNullOrEmpty(item["VAG_TON"].ToString()))
                {
                    amount.VAG_TON = decimal.Parse(item["VAG_TON"].ToString());
                }
                if (item["VAG_REMARK"] != null && !string.IsNullOrEmpty(item["VAG_REMARK"].ToString()))
                {
                    amount.VAG_REMARK = item["VAG_REMARK"].ToString();
                }

                if (item["VAG_INSERTDT"] != null && !string.IsNullOrEmpty(item["VAG_INSERTDT"].ToString()))
                {
                    amount.VAG_INSERTDT = DateTime.Parse(item["VAG_INSERTDT"].ToString());
                }
                if (item["VAG_INSERTUSER"] != null && !string.IsNullOrEmpty(item["VAG_INSERTUSER"].ToString()))
                {
                    amount.VAG_INSERTUSER = item["VAG_INSERTUSER"].ToString();
                }
                if (item["VAG_VOL"] != null && !string.IsNullOrEmpty(item["VAG_VOL"].ToString()))
                {
                    amount.VAG_VOL = decimal.Parse(item["VAG_VOL"].ToString());
                }
                voyage.Add(amount);
            }
            return voyage;
        }


        #region add by hwl

        /// <summary>
        /// 获取航航班船信息
        /// </summary>
        /// <param name="strWhere"></param>
        /// <param name="strOrder"></param>
        /// <returns></returns>
        public List<WEB_VM_LINERS> GetVMLines(string strWhere, string strOrder)
        {
            //  BLL.SystemManagement
            VesselsBLL vesselBll = new VesselsBLL();

            List<WEB_VM_LINERS> models = new List<WEB_VM_LINERS>();

            DataTable dt = vesselBll.GetTable(strWhere, strOrder);

            if (dt != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DataRow dr = dt.Rows[i];
                    WEB_VM_LINERS model = new WEB_VM_LINERS();
                    if (dr["LNR_ID"] != null && dr["LNR_ID"].ToString() != "")
                    {
                        model.LNR_ID = decimal.Parse(dr["LNR_ID"].ToString());
                    }
                    if (dr["LNR_VSL_CD"] != null && dr["LNR_VSL_CD"].ToString() != "")
                    {
                        model.LNR_VSL_CD = dr["LNR_VSL_CD"].ToString();
                    }
                    if (dr["LNR_FLT_ID"] != null && dr["LNR_FLT_ID"].ToString() != "")
                    {
                        model.LNR_FLT_ID = decimal.Parse(dr["LNR_FLT_ID"].ToString());
                    }
                    if (dr["LNR_NO"] != null && dr["LNR_NO"].ToString() != "")
                    {
                        model.LNR_NO = decimal.Parse(dr["LNR_NO"].ToString());
                    }
                    if (dr["LNR_ISTEP"] != null && dr["LNR_ISTEP"].ToString() != "")
                    {
                        model.LNR_ISTEP = decimal.Parse(dr["LNR_ISTEP"].ToString());
                    }
                    if (dr["LNR_ESTEP"] != null && dr["LNR_ESTEP"].ToString() != "")
                    {
                        model.LNR_ESTEP = decimal.Parse(dr["LNR_ESTEP"].ToString());
                    }
                    if (dr["LNR_IVOYAGE"] != null && dr["LNR_IVOYAGE"].ToString() != "")
                    {
                        model.LNR_IVOYAGE = dr["LNR_IVOYAGE"].ToString();
                    }
                    if (dr["LNR_EVOYAGE"] != null && dr["LNR_EVOYAGE"].ToString() != "")
                    {
                        model.LNR_EVOYAGE = dr["LNR_EVOYAGE"].ToString();
                    }
                    if (dr["LNR_SERLINE_ID"] != null && dr["LNR_SERLINE_ID"].ToString() != "")
                    {
                        model.LNR_SERLINE_ID = decimal.Parse(dr["LNR_SERLINE_ID"].ToString());
                    }
                    if (dr["LNR_INSERTDT"] != null && dr["LNR_INSERTDT"].ToString() != "")
                    {
                        model.LNR_INSERTDT = DateTime.Parse(dr["LNR_INSERTDT"].ToString());
                    }
                    if (dr["LNR_INSERTUSER"] != null && dr["LNR_INSERTUSER"].ToString() != "")
                    {
                        model.LNR_INSERTUSER = dr["LNR_INSERTUSER"].ToString();
                    }
                    if (dr["LNR_LSTUPDDT"] != null && dr["LNR_LSTUPDDT"].ToString() != "")
                    {
                        model.LNR_LSTUPDDT = DateTime.Parse(dr["LNR_LSTUPDDT"].ToString());
                    }
                    if (dr["LNR_LSTUPUSER"] != null && dr["LNR_LSTUPUSER"].ToString() != "")
                    {
                        model.LNR_LSTUPUSER = dr["LNR_LSTUPUSER"].ToString();
                    }
                    if (dr["LNR_VSL_ID"] != null && dr["LNR_VSL_ID"].ToString() != "")
                    {
                        model.LNR_VSL_ID = decimal.Parse(dr["LNR_VSL_ID"].ToString());
                    }
                    if (dr["VSL_CNNAME"] != null && dr["VSL_CNNAME"].ToString() != "")
                    {
                        model.VSL_CNNAME = dr["VSL_CNNAME"].ToString();
                    }
                    if (dr["VSL_ENNAME"] != null && dr["VSL_ENNAME"].ToString() != "")
                    {
                        model.VSL_ENNAME = dr["VSL_ENNAME"].ToString();
                    }
                    if (dr["LNR_IAMOUNT"] != null && dr["LNR_IAMOUNT"].ToString() != "")
                    {
                        model.LNR_IAMOUNT = decimal.Parse(dr["LNR_IAMOUNT"].ToString());
                    }
                    if (dr["LNR_EAMOUNT"] != null && dr["LNR_EAMOUNT"].ToString() != "")
                    {
                        model.LNR_EAMOUNT = decimal.Parse(dr["LNR_EAMOUNT"].ToString());
                    }
                    if (dr["FLIGHT_LOW_VALUE"] != null && dr["FLIGHT_LOW_VALUE"].ToString() != "")
                    {
                        model.FLIGHT_LOW_VALUE = dr["FLIGHT_LOW_VALUE"].ToString();
                    }
                    if (dr["AGENT"] != null && dr["AGENT"].ToString() != "")
                    {
                        model.AGENT = decimal.Parse(dr["AGENT"].ToString());
                    }
                    models.Add(model);
                }

            }
            return models;
        }



        /// <summary>
        /// 获取航班信息
        /// </summary>
        /// <param name="strWhere"></param>
        /// <param name="strOrder"></param>
        /// <returns></returns>
       public List<WEB_VM_FLIGHTS> GetFlights(string strWhere, string strOrder)
        {
            FlightInfoBLL bll = new FlightInfoBLL();
            DataTable dt = bll.GetTable(strWhere, strOrder);
            List<WEB_VM_FLIGHTS> lists = new List<WEB_VM_FLIGHTS>();
            if (dt != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DataRow dr = dt.Rows[i];
                    WEB_VM_FLIGHTS model = new WEB_VM_FLIGHTS();


                    if (dr["FLT_ID"] != null && dr["FLT_ID"].ToString() != "")
                    {
                        model.FLT_ID = decimal.Parse(dr["FLT_ID"].ToString());
                    }

                    if (dr["SLN_SRT_ID"] != null && dr["SLN_SRT_ID"].ToString() != "")
                    {
                        model.SLN_SRT_ID = decimal.Parse(dr["SLN_SRT_ID"].ToString());
                    }
                    if (dr["FLT_SLN_ID"] != null && dr["FLT_SLN_ID"].ToString() != "")
                    {
                        model.FLT_SLN_ID = decimal.Parse(dr["FLT_SLN_ID"].ToString());
                    }
                    if (dr["SLN_NAME"] != null && dr["SLN_NAME"].ToString() != "")
                    {
                        model.SLN_NAME = dr["SLN_NAME"].ToString();
                    }
                    if (dr["FLT_NO"] != null && dr["FLT_NO"].ToString() != "")
                    {
                        model.FLT_NO = decimal.Parse(dr["FLT_NO"].ToString());
                    }
                    if (dr["FLT_SCHDUL"] != null && dr["FLT_SCHDUL"].ToString() != "")
                    {
                        model.FLT_SCHDUL = dr["FLT_SCHDUL"].ToString();
                    }
                    if (dr["SCHDUL_NAME"] != null && dr["SCHDUL_NAME"].ToString() != "")
                    {
                        model.SCHDUL_NAME = dr["SCHDUL_NAME"].ToString();
                    }
                    if (dr["FLT_CYCLE"] != null && dr["FLT_CYCLE"].ToString() != "")
                    {
                        model.FLT_CYCLE = decimal.Parse(dr["FLT_CYCLE"].ToString());
                    }
                    if (dr["FLT_INITDT"] != null && dr["FLT_INITDT"].ToString() != "")
                    {
                        model.FLT_INITDT = DateTime.Parse(dr["FLT_INITDT"].ToString());
                    }
                    if (dr["FLT_FIXSCDSHP"] != null && dr["FLT_FIXSCDSHP"].ToString() != "")
                    {
                        model.FLT_FIXSCDSHP = dr["FLT_FIXSCDSHP"].ToString();
                    }
                    if (dr["FLT_VALIDFG"] != null && dr["FLT_VALIDFG"].ToString() != "")
                    {
                        model.FLT_VALIDFG = dr["FLT_VALIDFG"].ToString();
                    }
                    if (dr["FLT_IAMOUNT"] != null && dr["FLT_IAMOUNT"].ToString() != "")
                    {
                        model.FLT_IAMOUNT = decimal.Parse(dr["FLT_IAMOUNT"].ToString());
                    }
                    if (dr["FLT_EAMOUNT"] != null && dr["FLT_EAMOUNT"].ToString() != "")
                    {
                        model.FLT_EAMOUNT = decimal.Parse(dr["FLT_EAMOUNT"].ToString());
                    }
                    if (dr["FLT_DOCKHOUR"] != null && dr["FLT_DOCKHOUR"].ToString() != "")
                    {
                        model.FLT_DOCKHOUR = decimal.Parse(dr["FLT_DOCKHOUR"].ToString());
                    }
                    if (dr["FLT_INSERTDT"] != null && dr["FLT_INSERTDT"].ToString() != "")
                    {
                        model.FLT_INSERTDT = DateTime.Parse(dr["FLT_INSERTDT"].ToString());
                    }
                    if (dr["FLT_INSERTUSER"] != null && dr["FLT_INSERTUSER"].ToString() != "")
                    {
                        model.FLT_INSERTUSER = dr["FLT_INSERTUSER"].ToString();
                    }
                    if (dr["FLT_LSTUPDDT"] != null && dr["FLT_LSTUPDDT"].ToString() != "")
                    {
                        model.FLT_LSTUPDDT = DateTime.Parse(dr["FLT_LSTUPDDT"].ToString());
                    }
                    if (dr["FLT_LSTUPUSER"] != null && dr["FLT_LSTUPUSER"].ToString() != "")
                    {
                        model.FLT_LSTUPUSER = dr["FLT_LSTUPUSER"].ToString();
                    }
                    if (dr["FLT_TER_CST_ID"] != null && dr["FLT_TER_CST_ID"].ToString() != "")
                    {
                        model.FLT_TER_CST_ID = decimal.Parse(dr["FLT_TER_CST_ID"].ToString());
                    }
                    if (dr["TER_NAME"] != null && dr["TER_NAME"].ToString() != "")
                    {
                        model.TER_NAME = dr["TER_NAME"].ToString();
                    }
                    if (dr["FLT_IEFG"] != null && dr["FLT_IEFG"].ToString() != "")
                    {
                        model.FLT_IEFG = dr["FLT_IEFG"].ToString();
                    }
                    if (dr["FLT_STARTM"] != null && dr["FLT_STARTM"].ToString() != "")
                    {
                        model.FLT_STARTM = DateTime.Parse(dr["FLT_STARTM"].ToString());
                    }
                    if (dr["FLT_ENDDT"] != null && dr["FLT_ENDDT"].ToString() != "")
                    {
                        model.FLT_ENDDT = DateTime.Parse(dr["FLT_ENDDT"].ToString());
                    }
                    if (dr["FLT_REMARK"] != null && dr["FLT_REMARK"].ToString() != "")
                    {
                        model.FLT_REMARK = dr["FLT_REMARK"].ToString();
                    }
                    if (dr["AGENT"] != null && dr["AGENT"].ToString() != "")
                    {
                        model.AGENT = decimal.Parse(dr["AGENT"].ToString());
                    }
                    if (dr["AGENT_NAME"] != null && dr["AGENT_NAME"].ToString() != "")
                    {
                        model.AGENT_NAME = dr["AGENT_NAME"].ToString();
                    }
                    lists.Add(model);

                }
            }

            return lists;


        }


        /// <summary>
        /// 执行航班的增加、删除、修改操作
        /// </summary>
        /// <param name="operationType"></param>
        /// <param name="userID"></param>
        /// <param name="model"></param>
        /// <returns></returns>
     
        public string IUDForFlight(int operationType, int userID, WEB_VM_FLIGHTS model)
        {
            FlightInfoBLL bll = new FlightInfoBLL();
            return bll.InsertUpdateDeleteOperation(operationType, userID, model);
        }

        /// <summary>
        /// 根据用户ID获取船代理ID
        /// </summary>
        /// <param name="userID"></param>
        /// <returns></returns>
        public string GetAgentIDByUserID(int userID)
        {
            DataTable shipAgent = FlightInfoBLL.GetShipAgency(userID);
            if (shipAgent != null && shipAgent.Rows.Count > 0)
            {
                if (shipAgent.Rows[0] != null)
                    return shipAgent.Rows[0]["cst_id"].ToString();
            }
            return "";
        }


        /// <summary>
        /// 航班船的增加、删除 、修改操作
        /// </summary>
        /// <param name="operationType"></param>
        /// <param name="userID"></param>
        /// <param name="model"></param>
        /// <returns></returns>
        public string IUDForVessel(int operationType, int userID, WEB_VM_LINERS model)
        {
            VesselsBLL bll = new VesselsBLL();
            return bll.InsertUpdateDeleteOperation(operationType, userID, model);
        }



        /// <summary>
        /// 获取班期配置表
        /// </summary>
        /// <returns></returns>
        public List<string> GetFltSchedule()
        {
            DataTable dt = FlightInfoBLL.GetFLT_SCHDUL();
            List<string> lists = new List<string>();
            if (dt != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DataRow dr = dt.Rows[i];
                    if (dr["RV_LOW_VALUE"] != null)
                    {
                        lists.Add(dr["RV_LOW_VALUE"].ToString());
                    }
                }
            }
            return lists;
        }
        #endregion
    }//end class
}
